package com.tcu.result;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class R {
//    private Boolean isSuccess;
    private Integer code;
    private String message;
    private Map<String,Object> data=new HashMap<>();

    private R(){

    };
    public static R success(){
        R r = new R();
//        r.setIsSuccess(true);
        r.setCode(ResultCode.SUCCESS);
        r.setMessage("成功");
        return r;
    }
    public static R error(){
        R r = new R();
//        r.setIsSuccess(false);
        r.setCode(ResultCode.ERROR);
        r.setMessage("失败");
        return r;
    }
    public R success(Boolean isSuccess){
//        this.isSuccess = isSuccess;
        return this;
    }
    public R message(String message){
        this.message = message;
        return this;
    }
    public R data(String key,Object val){
        this.data.put(key, val);
        return this;
    }
}
